<template>
	<view class="box" style=" ">
		<view class="bor">
			<view class="box1">
				<text style="margin-right: 40rpx; width: 20%;">收货人</text>
				<input style="width: 80%; margin-top: 14px;" type="text" placeholder="收货人姓名">
			</view>
			<view class="box1">
				<text style="margin-right: 40rpx; width: 20%;">手机号码</text>
				<input style="width: 80%; margin-top: 14px;" type="text" placeholder="收货人手机号码">
			</view>
			<view class="box1">
				<text class="di" style="margin-right: 40rpx; width: 20%;" @click="fn1">所在地区</text>
				<u-picker  :show="show" ref="uPicker" :columns="columns" @confirm="confirm" @change="changeHandler">
				</u-picker>
			</view>
			<view class="box1">
				<text style="margin-right: 40rpx; width: 20%;">详细地址</text>
				<input style="width: 80%; margin-top: 14px;" type="text" placeholder="街道门牌、楼层房间号等信息">
			</view>
			<view class="box2" style="margin-top: 10px; ">
				<text style="margin-right: 40rpx; width: 20%;">设为默认收货地址</text>
				<u-switch class="A" v-model="value" @change="change"></u-switch>
			</view>
				<button @click="fn">保存</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				show: true,
				columns: [
					['中国', '美国'],
					['深圳', '厦门', '上海', '拉萨']
				],
				columnData: [
					['深圳', '厦门', '上海', '拉萨'],
					['得州', '华盛顿', '纽约', '阿拉斯加']
				],
				
				}
			},
			fn1(){
				
			},
			methods:{
				changeHandler(e) {
					const {
						columnIndex,
						value,
						values, // values为当前变化列的数组内容
						index,
						// 微信小程序无法将picker实例传出来，只能通过ref操作
						picker = this.$refs.uPicker
					} = e
					// 当第一列值发生变化时，变化第二列(后一列)对应的选项
					if (columnIndex === 0) {
						// picker为选择器this实例，变化第二列对应的选项
						picker.setColumnValues(1, this.columnData[index])
					}
				},
				// 回调参数为包含columnIndex、value、values
				confirm(e) {
					console.log('confirm', e)
					this.show = false
				}
			}
		}
</script>

<style lang="scss">
	.bor {
		margin: 0 40px 0px 40px;
		background-color: aqua;
		border-radius: 10rpx;
	}

	.box {
		width: 100%;
		height: 100vh;
		// background-color: red;
	}

	.box1 {
		// width: 80%;
		height: 50rpx;
		line-height: 50px;
		margin: 0 40px 0px 40px;
		// background-color: chartreuse;
		display: flex;
	}
	.box2{
		height: 50rpx;
		line-height: 50px;
		margin: 0 40px 0px 40px;
		// background-color: chartreuse;
		position: relative;
	}
	.A {
		position: absolute;
		right: 0;
		top: 15rpx;
	}
	button {
		width: 100%;
		background-color: #1BA784;
		color: white;
		outline: none;
		border-radius: 30px;
		position: fixed;
		bottom: 0;
		right: 0;
	}
</style>
